subroutine fatal_error(msg)

  ! fatal_error: exception handling, to be invoked
  !   whenever a fatal error occurs.
  !   dumps a message at stdout and halts execution

  implicit none
  include "mpif.h"
  
  character(len=*), intent(in) :: msg
  integer :: ierr

  write(*,"(a)") "**(ERROR)**"//msg
  write(*,"(a)") "*** BRAMS execution halts (see previous error msg) ***"
  call MPI_Abort(MPI_COMM_WORLD, 1, ierr)
  stop

end subroutine fatal_error
